<?php

//分类模型
class CategoryModel extends Model{
	public $table='category';
	
	public $validate=array(
	  array('cname','nonull','分类名不能为空',2,3)
	  
	);
	
	
	//添加顶级分类
	public function addData(){
		if(!$this->create()){
			return false;
		}
		
		
		return $this->add();
	}
	
	//获得cid所对应的所有子集
	public function sonCid($data,$cid){
		static $temp=array();
		foreach($data as $v){
			if($v['pid']==$cid){
				$temp[]=$v['cid'];
				$this->sonCid($data, $v['cid']);
			}
		}
		return $temp;
	}
	
}


?>